/**
 * @Author：ming
 * @Date：2023/10/4 12:50 AM
 * @Filename：Lc55
 */

/**
 * @author ming
 */
public class Lc55 {
    public boolean canJump(int[] nums) {
       int len = nums.length;
        boolean[] dp = new boolean[len];
        dp[len-1]=true;

        for (int i = len-2; i >=0 ; i--) {
            int temp = nums[i];
            for (int j = 1; j < temp; j++) {
                if(i+j<len){
                    dp[i] = dp[i+j];
                    if(dp[i]){
                        break;
                    }
                }else {
                    dp[i]=true;
                    break;
                }
            }
        }


        return dp[0];
    }

}

